//
//  SearchListCell.m
//  PaiLeXiongProject
//
//  Created by 小獾科技 on 2017/8/30.
//  Copyright © 2017年 小獾科技. All rights reserved.
//

#import "SearchListCell.h"

@interface SearchListCell ()
@property (nonatomic, strong) UILabel *currentPriceLabel;
@property (nonatomic, strong) UILabel *originalPriceLabel;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *saleNumberLabel;
@end
@implementation SearchListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _currentPriceLabel = [UILabel new];
        _currentPriceLabel.text = @"¥580";
        _currentPriceLabel.textColor = ColorFrom16(0xFF5B7A);
        _currentPriceLabel.font = PFRFONT(18);
        [self addSubview:_currentPriceLabel];
        [_currentPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(11);
            make.left.equalTo(self).offset(30);
            make.width.lessThanOrEqualTo(@80);
            make.height.equalTo(@25);
        }];
        
        _titleLabel = [UILabel new];
        _titleLabel.text = @"爱儿美儿童摄影秋季梦想儿童摄影";
        _titleLabel.textColor = ColorFrom16(0x323232);
        _titleLabel.font = PFRFONT(14);
        _titleLabel.textAlignment = 0;
        [self addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self).offset(13);
            make.left.equalTo(_currentPriceLabel.mas_right).offset(15);
            make.right.equalTo(self).offset(-10);
            make.height.equalTo(@20);
        }];
        
        _originalPriceLabel = [UILabel new];
        _originalPriceLabel.text = @"¥620";
        _originalPriceLabel.textColor = ColorFrom16(0x999999);
        _originalPriceLabel.font = PFRFONT(14);
        [self addSubview:_originalPriceLabel];
        [_originalPriceLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_currentPriceLabel.mas_bottom);
            make.left.equalTo(self).offset(34);
            make.width.greaterThanOrEqualTo(@20);
            make.height.equalTo(@20);
        }];
        _saleNumberLabel = [UILabel new];
        _saleNumberLabel.text = @"已售 20";
        _saleNumberLabel.textColor = ColorFrom16(0x7F7E7D);
        _saleNumberLabel.font = PFRFONT(11);
        [self addSubview:_saleNumberLabel];
        [_saleNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_titleLabel.mas_bottom).offset(5);
            make.left.equalTo(_originalPriceLabel.mas_right).offset(5);
            make.width.greaterThanOrEqualTo(@40);
            make.height.equalTo(@16);
        }];
    }
    return self;
}

- (void)configViewWithModel:(DataModel *)model
{
    _currentPriceLabel.text = [NSString stringWithFormat:@"￥%@", model.sale_price];
    _originalPriceLabel.text = [NSString stringWithFormat:@"￥%@", model.goods_price];
    _originalPriceLabel.attributedText = [GW_Tool setCutLine:_originalPriceLabel.text];
    _titleLabel.text = model.goods_name;
    _saleNumberLabel.text = [NSString stringWithFormat:@"已售 %@", model.goods_sold];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
